#include<stdio.h>
#include<stack>
#include<string>
#include<queue>
#include<iostream>
using namespace std;
struct Node{
	char data;
	struct Node* left;
	struct Node* right;
};
typedef Node* BTree;
void sks(BTree BT);
BTree CreateBTree(string str,int i);
int main(){
	BTree BT;
		char ch;
	char str[50];
	int i=0,flag=1;
	while((ch=getchar())!='\n' ){
		str[i]=ch;
		i++;
	}
//	str[i]='\0';
	BT=CreateBTree(str,1);
	sks(BT);
	
}
BTree CreateBTree(string str,int i)
{
   int len;
   BTree bt;
   bt=new Node;
   len=str.size();
   cout<<len<<endl;
   if(i>len-1 || i<=0) return NULL;
   if(str[i]=='#') return NULL;
   bt->data =str[i];
   bt->left =CreateBTree(str,2*i); 
   bt->right =CreateBTree(str,2*i+1); 	
   return bt;
}
void sks(BTree BT){
	int flag=1;
	if(!BT){
	cout<<"NULL";
	return;
	}
	BTree t;
	queue<BTree>q;
	q.push(BT);
	while(!q.empty()){
		t=q.front();
		q.pop();
		if(flag){
		cout<<t->data;	
		flag=0;		
		}
		else
		cout<<" "<<t->data;
		if(t->left) q.push(t->left);
		if(t->right) q.push(t->right);		
	}		
}

